package com.ruoyi.web.controller.flowable;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ApproveCarbonCopy;
import com.ruoyi.system.service.IApproveCarbonCopyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 审批抄送Controller
 *
 * @author ruoyi
 * @date 2024-03-27
 */
@RestController
@RequestMapping("/flowable/approve/copy")
public class ApproveCarbonCopyController extends BaseController
{
    @Autowired
    private IApproveCarbonCopyService approveCarbonCopyService;

    /**
     * 查询审批抄送列表
     */
    @PreAuthorize("@ss.hasPermi('system:copy:list')")
    @GetMapping("/list")
    public TableDataInfo list(ApproveCarbonCopy approveCarbonCopy)
    {
        startPage();
        List<ApproveCarbonCopy> list = approveCarbonCopyService.selectApproveCarbonCopyList(approveCarbonCopy);
        return getDataTable(list);
    }

    /**
     * 导出审批抄送列表
     */
    @PreAuthorize("@ss.hasPermi('system:copy:export')")
    @Log(title = "审批抄送", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ApproveCarbonCopy approveCarbonCopy)
    {
        List<ApproveCarbonCopy> list = approveCarbonCopyService.selectApproveCarbonCopyList(approveCarbonCopy);
        ExcelUtil<ApproveCarbonCopy> util = new ExcelUtil<ApproveCarbonCopy>(ApproveCarbonCopy.class);
        util.exportExcel(response, list, "审批抄送数据");
    }

    /**
     * 获取审批抄送详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:copy:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(approveCarbonCopyService.selectApproveCarbonCopyById(id));
    }

    /**
     * 新增审批抄送
     */
    @PreAuthorize("@ss.hasPermi('system:copy:add')")
    @Log(title = "审批抄送", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ApproveCarbonCopy approveCarbonCopy)
    {
        return toAjax(approveCarbonCopyService.insertApproveCarbonCopy(approveCarbonCopy));
    }

    /**
     * 修改审批抄送
     */
    @PreAuthorize("@ss.hasPermi('system:copy:edit')")
    @Log(title = "审批抄送", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ApproveCarbonCopy approveCarbonCopy)
    {
        return toAjax(approveCarbonCopyService.updateApproveCarbonCopy(approveCarbonCopy));
    }

    /**
     * 删除审批抄送
     */
    @PreAuthorize("@ss.hasPermi('system:copy:remove')")
    @Log(title = "审批抄送", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable String id)
    {
        return toAjax(approveCarbonCopyService.deleteApproveCarbonCopyById(id));
    }
}
